package com.basic.tcp2;

import com.basic.entity.User;

import javax.sound.midi.Soundbank;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.sql.SQLOutput;

public class LoginServer {

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ServerSocket ss = new ServerSocket(8800);
        Socket socket = ss.accept();

//        DataInputStream dis = new DataInputStream(socket.getInputStream());
//        String result = dis.readUTF();
//        System.out.println(result);

        ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
        User user = (User)ois.readObject();
        System.out.println(user);


        //响应客户端
        DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
        if(user != null && "lyx".equals(user.getName()))
            dos.writeUTF("你好,登录成功！");
        else
            dos.writeUTF("输入错误！");
        dos.close();
        ois.close();
        socket.close();
        ss.close();
    }
}
